<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>春节返安人员申报</title>
    <style>
        * {
            background: #f0f0f0;
        }

        .every_wrap {
            background: #fff;
            padding: 4% 4%;
            width: 86%;
            margin-left: 3%;
            margin-top: 30px;
        }

        .name {
            font-size: 14px;
            color: #999;
            background: #fff;
            line-height: 20px;
        }

        .result {
            font-size: 16px;
            color: red;
            background: #fff;
            line-height: 26px;
        }

        .reason {
            color: red;
            font-size: 16px;
            background: #fff;
            line-height: 26px;
        }
        .htmls {
        min-height: 480px;
    }
    .tishi {
        text-align: center;
        color: #666;
        font-size: 14px;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    </style>
</head>

<body>
    <div class="htmls">
        <h3 style="text-align: center;">查询结果</h3>
        <div class="wrap">
        </div>
    </div>
    <img src="http://hesuan.city1000.cn/images/tishi.png" alt="" width="90%"
            style="margin-left: 4%;margin-top: 20px;">
        <div class="tishi">技术支持: 智慧安平</div>
    <script src="./jquery/jquery.min.js"></script>
    <script>
        // 获取code
        function getQueryVariable(variable) {
            // 参数 window.location.search
            var query = decodeURI(window.location.search.substring(1));
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return pair[1];
                }
            }
            return (false);
        }
        var code = getQueryVariable('code')
        $.ajax({
            url: "http://39.99.164.177:8082/api/getResult?code=" + code,
            success: function (res) {
                console.log(res)
                if (res.code == 0) {
                    if (res.data.length > 0) {
                        var arrs = []
                        for (let i = 0; i < res.data.length; i++) {
                            if (res.data[i].due == 0) {
                                arrs.push('待处理')
                            } else if (res.data[i].due == 1) {
                                arrs.push('通过')
                            } else {
                                arrs.push('劝返')
                            }
                            console.log(arrs)
                            if (res.data[i].due == 2) {
                                $('.wrap').append(`<div class="every_wrap">
                    <div class="name">${res.data[i].name}(${res.data[i].phone})</div>
                      <div class="result">${arrs[i]}</div>
                      <div class="reason">劝返原因:${res.data[i].remarks}</div>
                  </div>`)
                            } else {
                                $('.wrap').append(`<div class="every_wrap">
                      <div class="name">${res.data[i].name}(${res.data[i].phone})</div>
                      <div class="result">${arrs[i]}</div>
                  </div>`)
                            }
                        }
                    } else {
                        $('.wrap').append(`<div style='text-align:center'>暂无数据</div>`)
                    }
                }
            },
            error: function (err) {
                console.log(err)
            }
        })
    </script>
</body>

</html>